package biz

import "context"

type OrderUseCase struct {
	repo OrderRepo
}

func NewOrderUseCase(repo OrderRepo) *OrderUseCase {
	return &OrderUseCase{
		repo: repo,
	}
}

type Order struct {
	Id      int64
	UserId  int64
	Details []*Product
}

type Product struct {
	Id   int64
	Name string
	Num  int64
}

type OrderRepo interface {
	CreateOrder(ctx context.Context, order *Order) (*Order, error)
	GetOrder(ctx context.Context, id int64) (*Order, error)
	ListOrder(ctx context.Context, pageNum int64, pageSize int64) ([]*Order, error)
}

func (uc *OrderUseCase) CreateOrder(ctx context.Context, order *Order) (*Order, error) {
	return uc.repo.CreateOrder(ctx, order)
}

func (uc *OrderUseCase) GetOrder(ctx context.Context, id int64) (*Order, error) {
	return uc.repo.GetOrder(ctx, id)
}

func (uc *OrderUseCase) ListOrder(ctx context.Context, pageNum int64, pageSize int64) ([]*Order, error) {
	return uc.repo.ListOrder(ctx, pageNum, pageSize)
}
